package Aleehot100;

/**
 * ClassName: c037
 * Package: Aleehot100
 * Description: 求树的最大的深度
 *
 * @Author BCXJ
 * @Create 2025/7/6 12:38
 * @Version 1.0
 * @Since 1.0
 */
public class c037 {
    public static void main(String[] args) {

    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public static int maxDepth(TreeNode root) {
        return root == null ? 0 : Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }
}
